﻿using System;
using System.Collections.Generic;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MoMoTransferVN_WP.utils
{
    class SettingUtils
    {

        public static void saveSetting(string key, object value)
        {

            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            if (!settings.Contains(key))
            {
                settings.Add(key, value);
            }
            else
            {
                settings[key] = value;
            }
            settings.Save();
        }

        public static string readString(String key)
        {
         
            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            if (settings.Contains(key) && (settings[key] as string) != null)
            {
                return settings[key] as string;
            }

            return String.Empty;
        }


        public static bool readBool(String key)
        {

            IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
            if (settings.Contains(key))
            {
                return Convert.ToBoolean(settings[key]);
            }
            return false;
        }
    }

}
